package com.dg.river.wxapi;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;

import androidx.annotation.Nullable;

import com.dg.river.core.MyApplication;
import com.dg.river.core.util.L;
import com.tencent.mm.opensdk.modelbase.BaseReq;
import com.tencent.mm.opensdk.modelbase.BaseResp;
import com.tencent.mm.opensdk.openapi.IWXAPIEventHandler;

/**
 * Created by hy on 2018/11/7
 * Description : 微信回调类
 */
public class WXEntryActivity extends Activity implements IWXAPIEventHandler {

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        MyApplication.getInstance().wxapi.handleIntent(getIntent(), this);
    }

    @Override
    protected void onNewIntent(Intent intent) {
        super.onNewIntent(intent);
        MyApplication.getInstance().wxapi.handleIntent(getIntent(), this);
    }

    @Override
    public void onReq(BaseReq baseReq) {

    }

    @Override
    public void onResp(BaseResp baseResp) {
        L.d("-- " + baseResp.errStr);
        L.d("-- " + baseResp.errCode);
        int type = baseResp.getType();
        switch (baseResp.errCode) {
            case BaseResp.ErrCode.ERR_OK:
                finish();
                break;
            case BaseResp.ErrCode.ERR_AUTH_DENIED://授权拒绝
                finish();
                break;
            case BaseResp.ErrCode.ERR_USER_CANCEL:
                finish();
                break;
        }
    }
}
